<% if controller.action_name=="tag" %>
<div id="tag">Popular blogs tagged "<b><%= @tag.name %></b>" </div> 
<% end %>
<br />
<!-- copy from blogs/list :plus [blog] before all the blog -->
<table>
  <tr>
    <th>Rank</th>	 
    <th>Name</th>
	<th>Tag</th> 
	<th>Add</th> 
	<th>Score</th> 
	<th>Push</th> 
  </tr>
  
<% for blog in @blogtag %>
  <tr>
  	<td><%= link_to_remote ( blog.blog.rank,
                            :update => 'main',
                            :url => { :action => :show,:id => blog.blog }) %>
    </td>
	<td><%= link_to_remote ( blog.blog.name,
                            :update => 'main',
                            :url => { :action => :show,:id => blog.blog }) %>
    </td>
<% if controller.action_name=="hot" %>
   <td><%= link_to_remote ( h(blog.tag.name),
                            :update => 'main',
                            :url => { :action => :tag,:id => blog.tag.id }) %>
   </td>
<% else %>
	<%
	blogtag = Blogtag.find(:first,:order => "times DESC", :conditions => [ "blog_id = ?", blog.blog.id])
    if blogtag==nil
    %>
	<td><%= link_to_remote ( "null",
                            :update => 'main',
                            :url => { :action => :show,:id => blog.blog }) %>
    </td>
	<% else %>
	<td><%= link_to_remote ( h(blogtag.tag.name),
                            :update => 'main',
                            :url => { :action => :tag,:id => blogtag.tag.id }) %>
    </td>
	<% end %>
<% end %>
	<td>
<%= start_form_tag :action => 'tagging' %>
<%= hidden_field_tag("blog",blog.blog.id) %>
<%= text_field_with_auto_complete :tag, :name, { :size => 16 }, {:tokens => ' '} %>
<%= image_submit_tag "tag_button.gif" %>  
<%= end_form_tag %> 
	</td>
	<td id=<%=blog.blog.id%>>  <%=h blog.blog.click %></td>
	<td><%= link_to_remote ( image_tag("push.gif",:border => 0),
                            :update => blog.blog.id,
                            :url => { :action => :push,:id => blog.blog.id }) %>
    </td>
  </tr>
<% end %>
</table>



